package com.itheima.mapper;

import com.itheima.dto.EmpDto;
import com.itheima.dto.EmpLoginDto;
import com.itheima.pojo.Emp;
import org.apache.ibatis.annotations.*;

import java.util.List;

/**
 * 员工管理
 */
@Mapper
public interface EmpMapper {

    /*@Select("select * from emp limit #{start},#{pageSize}")
    public List<Emp> getByPage(@Param("start") Integer start, @Param("pageSize") Integer pageSize);

    @Select("select count(*) from emp")
    public Long getTotal();*/

//不带条件的分页查询
    @Select("select * from emp")
    public List<Emp> getByPage();
//由分页插件自动添加limit，且自动计算满足dto条件的数量 带条件的分页查询
    List<Emp> getByPage2(EmpDto empDto);


    int deleteByIds(Integer[] ids);

    @Insert("insert into emp values (null,#{username},#{password},#{name},#{gender},#{image},#{job},#{entrydate},#{deptId},#{createTime},#{updateTime})")
    int insertEmp(Emp emp);

    @Select("select * from emp where username=#{username} and password=#{password}")
    Emp findByUsernameAndPassword(EmpLoginDto loginDto);

    @Delete("delete from emp where dept_id=#{deptId}")
    int delByDeptId(Integer deptId);
}


